<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 搜索插入的位置
        function seach(nums, target) {
            // console.log(nums, target);
            let left = 0;
            let right = nums.length - 1
            while (left <= right) {
                const mid = Math.floor((left + right) / 2);
                if (nums[mid] === target) {
                    return mid;
                } else if (nums[mid] < target) {
                    left = mid + 1
                } else {
                    right = mid - 1
                }
            }
            return left;
        }
        const arr = [3, 9, 92, 44];
        const re = seach(arr, 44);
        console.log(re);
    </script>
</body>

</html>